<?php

namespace app\admin\model;

use app\common\model\TimeModel;
use think\model\concern\SoftDelete;
use think\model\relation\HasMany;
use think\model\relation\HasOne;

class DataStoreUser extends TimeModel
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';

    protected $name = "data_store_user";

    protected $table = "";



    public function getStatusTextAttr($value,$data)
    {
        $status = [-1=>'拒绝',0=>'申请中',1=>'开启'];
        return $status[$data['status']];
    }

    public function getStoreTypeTextAttr($value,$data)
    {
        $status =DataStoreUserType::list();
        return $status[$data['store_type']];
    }


    public function main()
    {
        return $this->hasMany(DataStoreDecoration::class,'store_id','id')->where(['type'=>'main']);
    }

    public function abbreviations()
    {
        return $this->hasMany(DataStoreDecoration::class,'store_id','id')->where(['type'=>'abbreviations']);
    }

    public function decoration()
    {
        return $this->hasMany(DataStoreDecoration::class,'store_id','id');
    }


    public function lottery(){
        return $this->hasOne(DataStoreLottery::class,'store_id','id');
    }


}